﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebContratos.Bean;
using WAContratos;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace WebContratos.Manager
{
    public class UsuarioManager
    {
        public UsuarioBean obtieneDatosUsuario(string userUsuario)
        {
            UsuarioBean uBean = new UsuarioBean();

            if (!(String.IsNullOrEmpty(userUsuario)))
            {
                OracleCommand Comm = new OracleCommand();
                OracleConnection con = Conexion.Cone;
                Comm.Connection = con;
                Comm.CommandText = "PKG_WEB.proc_consulta_usuario";
                Comm.CommandType = CommandType.StoredProcedure;
                Comm.Parameters.Add("pcodRol", userUsuario);//         '    VARCHAR2,
                Comm.Parameters.Add("datos", OracleDbType.RefCursor).Direction = ParameterDirection.Output;//    ' OUT   cur,
                Comm.Parameters.Add("pcodError", OracleDbType.Varchar2, 3).Direction = ParameterDirection.Output;
                Comm.Parameters.Add("pMsgError", OracleDbType.Varchar2, 50).Direction = ParameterDirection.Output;


                OracleDataReader oReader;
                con.Open();
                oReader = Comm.ExecuteReader();

                while (oReader.Read())
                {
                    uBean.UserId = Convert.ToString(oReader.GetValue(0));
                    uBean.UserUsuario = Convert.ToString(oReader.GetValue(1));
                    uBean.UserClave = Convert.ToString(oReader.GetValue(2));
                    uBean.UserEmail = Convert.ToString(oReader.GetValue(3));
                    uBean.UserFecha = Convert.ToString(oReader.GetValue(4));
                    uBean.UserEstado = Convert.ToString(oReader.GetValue(5));
                    uBean.UserNombre = Convert.ToString(oReader.GetValue(6));
                    uBean.UserApellido = Convert.ToString(oReader.GetValue(7));
                    uBean.UserCambiado = Convert.ToString(oReader.GetValue(8));
                    uBean.UserLocalidad = Convert.ToString(oReader.GetValue(9));
                    uBean.UserDepartamento = Convert.ToString(oReader.GetValue(10));
                    uBean.UserFechaIngreso = Convert.ToString(oReader.GetValue(11));
                    uBean.UserFechaModificacion = Convert.ToString(oReader.GetValue(12));
                    uBean.UserUsuarioModificacion = Convert.ToString(oReader.GetValue(13));
                    uBean.UserUsuarioIngreso = Convert.ToString(oReader.GetValue(14));
                    uBean.UserFechaActualizacion = Convert.ToString(oReader.GetValue(15));
                    uBean.UserFechaActivacion = Convert.ToString(oReader.GetValue(16));
                    uBean.UserCodigoActivacion = Convert.ToString(oReader.GetValue(17));
                    uBean.Movil = Convert.ToString(oReader.GetValue(18));
                }

                Comm.Dispose();
                con.Close();
                GC.Collect();
            }
            return uBean;
        }
    }
}
